package sk.stuba.fiit.pki.ws.service;

import java.io.IOException;

import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;

public class CommUtil {
 	private static CommUtil communicator;
 	private BASE64Decoder decoder ;
	private	BASE64Encoder encoder ;
 		
 	private CommUtil() {
 		 decoder = new BASE64Decoder();
 		 encoder = new BASE64Encoder();
 		 communicator = this;
 	}
	
 	public String codeBase64ByteToString(byte[] data){
 		return encoder.encode(data); 		
 	}
 	
 	public byte[] codeBase64StringToByte(String data) throws IOException{
 		return decoder.decodeBuffer(data);
 	}
 	
	public static CommUtil getInstance(){
		if(communicator==null)
			return new CommUtil();
		return communicator;
	}
	
}
